package rsponse; /**
 * @author tongchen
 * resp响应字符流数据
 * @create 2022-11-29 12:45
 */

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet("/resp2.0")
public class resp2 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //确定响应格式
        response.setContentType("text/html;charset=utf-8");
        //响应数据
        PrintWriter writer = response.getWriter();
        writer.write("张三");
        writer.write("<h1>aaa</h1>");

    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
    }
}
